package edu.dayu;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@SpringBootApplication(exclude = {SecurityAutoConfiguration.class, ManagementWebSecurityAutoConfiguration.class})
public class Activiti7DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(Activiti7DemoApplication.class, args);

        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        TaskService taskService = processEngine.getTaskService();
        // Task 对象对应的是 act_ru_task 的记录。
        List<Task> tasks = taskService.createTaskQuery().taskAssignee("12").list();
        Map<String,Object> map = new HashMap<>();
        map.put("result","同意");
        map.put("sameDept",true);
//        map.put("notifyService","创建成功");
        for (Task task : tasks) {
            taskService.complete(task.getId(),map);
        }
    }

}
